import { Injectable } from '@nestjs/common';
import { HomeDao as Dao } from '@/servers/daos/home/home.dao';

@Injectable()
export class HomeService {

  constructor(private dao: Dao) { }

  /**
 * 获取灯杆，网关
 * @param params 
 */
  getBusiness(params: any) {
    return this.dao.getBusiness(params);
  }


  /**
  * 查询设备总数
  */
  getCounts(params: any) {

    const data = {
      left: [
        {
          name: '照明',
          icon: 'assets/images/home/icon_1.png',
          num: 233,
          unit: '盏',
          ratio: '30%'
        },
        {
          name: '监控',
          icon: 'assets/images/home/icon_2.png',
          num: 43,
          unit: '个',
          ratio: '20%'
        },
        {
          name: '媒体',
          icon: 'assets/images/home/icon_3.png',
          num: 45,
          unit: '台',
          ratio: '43%'
        },
        {
          name: '广播',
          icon: 'assets/images/home/icon_4.png',
          num: 122,
          unit: '台',
          ratio: '54%'
        }
      ],
      right: [
        {
          name: '气象',
          icon: 'assets/images/home/icon_5.png',
          num: 36,
          unit: '个',
          ratio: '78%'
        },
        {
          name: '报警',
          icon: 'assets/images/home/icon_6.png',
          num: 78,
          unit: '个',
          ratio: '56%'
        },
        {
          name: '充电',
          icon: 'assets/images/home/icon_7.png',
          num: 45,
          unit: '个',
          ratio: '87%'
        },
        {
          name: '5G',
          icon: 'assets/images/home/icon_8.png',
          num: 80,
          unit: '个',
          ratio: '54%'
        }
      ]
    };
    return data;//this.dao.getCounts(params);
  }

  /**
  * 获取气象数据
  */
  getSensor(params: any) {
    const datalist = [
      {
        val: '30%',
        key: '温度'
      },
      {
        val: '50%',
        key: '湿度'
      },
      {
        val: '51LUX',
        key: '光照度'
      },
      {
        val: 'ug/m',
        key: 'PM10'
      },
      {
        val: '37.0ug/m',
        key: 'PM2.5'
      },
      {
        val: '51LUX',
        key: '噪声'
      }
    ];
    return datalist;
  }

  /**
  * 获取告警统计
  */
  getAlert(params: any) {
    const datalist = [
      { value: 1048, name: '网络异常' },
      { value: 735, name: '设备离线' },
      { value: 580, name: '超限警报' },
      { value: 484, name: '其他上报' }
    ];
    return datalist;
  }

  /**
  * 获取能耗数据
  */
  getEnergy(params: any) {
    const datalist = [];
    for (let i = 1; i < 13; i++) {
      let num = Math.floor(Math.random() * 1000);
      let item = {
        month: i,
        value: num
      }
      datalist.push(item);
    }

    return datalist;
  }

  /**
   * 获取灯杆，网关
   * @param params 
   */
  getLamppost(params: any) {
    return this.dao.getGateWay(params);
  }


}
